package com.patrol.logisticsmanage.ui.equip;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.patrol.logisticsmanage.R;
import com.patrol.logisticsmanage.ui.todo.ToDoAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;

public class EquipDetailAdapter extends RecyclerView.Adapter<EquipDetailAdapter.ViewHolder> {
    Context context;
    ToDoAdapter.OnItemClickListener onItemClickListener;


    public EquipDetailAdapter(Context context) {
        this.context = context;
    }

    public void setOnItemClickListener(ToDoAdapter.OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    @NonNull
    @Override
    public EquipDetailAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_equip_detail, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.tvGoodsChange.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onItemClickListener.onItemClick(v,position);
            }
        });
    }

    @Override
    public int getItemCount() {
        return 3;
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.img_goods)
        ImageView imgGoods;
        @BindView(R.id.tv_goods_name)
        TextView tvGoodsName;
        @BindView(R.id.tv_goods_change)
        TextView tvGoodsChange;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
